package com.chrray.position.util.result;

import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Component
/*@JsonInclude(JsonInclude.Include.NON_NULL)*/
@Setter
@Getter
public class ResponseResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 返回信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private T data;
    /**
     * 总条数
     */
//    private Long total = 0L;

    /**
     * 不传参数，默认是成功
     */
    public ResponseResult() {
        this.code = ResultEnum.SUCCESS.getCode();
        this.msg = ResultEnum.SUCCESS.getMsg();
    }

    /**
     * 只传状态码和提示信息
     */
    public ResponseResult(Integer code,String msg) {
        this.code = code;
        this.msg =msg;
    }
    /**
     * 只传状态码和提示信息、和返回数据
     */
    public ResponseResult(Integer code,String msg,T data) {
        this.code = code;
        this.msg =msg;
        this.data=data;
    }
    /**
     * 只传状态码和提示信息、和返回数据、总条数
     */
/*    public ResponseResult(Integer code,String msg,T data,Long total) {
        this.code = code;
        this.msg =msg;
        this.data=data;
        this.total=total;
    }*/

}
